home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
PAD.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-04-02
|
26KB
|
620 lines
INTERRUPTS SEGMENT AT 0H ;This is where the keyboard interrupt
ORG 9H*4 ;holds the address of its service routine
KEYBOARD_INT LABEL WORD
ORG 21H*4 ;holds the address of its service routine
DOS_INT LABEL WORD
INTERRUPTS ENDS
SCREEN SEGMENT AT 0B000H ;A dummy segment to use as the
SCREEN ENDS ;Extra Segment
ROM_BIOS_DATA SEGMENT AT 40H ;BIOS statuses held here, also keyboard buffer
ORG 1AH
HEAD DW ? ;Unread chars go from Head to Tail
TAIL DW ?
BUFFER DW 16 DUP (?) ;The buffer itself
BUFFER_END LABEL WORD
ROM_BIOS_DATA ENDS
CODE_SEG SEGMENT
ASSUME CS:CODE_SEG
ORG 100H ;ORG = 100H to make this into a .COM file
FIRST: JMP LOAD_PAD ;First time through jump to initialize routine
COPY_RIGHT DB '(C)1987 S Holzner'
INT21 LABEL DWORD ;Point to next two words for jump.
OLD_DOS_INT DW 2 DUP(?) ;Store original DOS INT21 address here.
FIRST_FLAG DB 1 ;First time through? Get COMMAND address
COMMAND_ADDR DW ? ;Store IP of calling routine in COMMAND.
OLD_DS DW 1 ;Keep DS:DX of old keyboard buffer.
OLD_DX DW 1001H
KEY1 DB 'SAVE', 0DH
KEY2 DB 'save', 0DH
KEY3 DB 'Save'
CR DB 0DH,0AH,'$' ;Use this <cr> to send to DOS.
FILE_DONE DB 0DH,0AH,'PAD.TXT created.',0DH,0AH,'$'
CNTRL_N_FLAG DW 0 ;Cntrl-N on or off
FILENAME DB 'PAD.TXT',0
PAD_CURSOR DW 0 ;Current position in pad
CURSOR_STORAGE DW 0,600,1200,1800,2400 ;Hold cursor each page.
PAD_OFFSET DW 0 ;Chooses 1st 250 bytes or 2nd
PAD_BEGIN DW 0 ;Beginning of current page.
PAD_END DW 599 ;End of current page.
PAGE_NUMBER DW 0 ;Page Number 0-4.
FIRST_POSITION DW ? ;Position of 1st char on screen
ATTRIBUTE DB 112 ;Pad Attribute: 1EH better for color screens
FORE_ATTR DB 0
BACK_ATTR DB 0
SCREEN_SEG_OFFSET DW 0 ;0 for mono, 8000H for graphics
IO_CHAR DW ? ;Holds addr of Put or Get_Char
STATUS_PORT DW ? ;Video controller status port
OLD_KEY_INT LABEL WORD
OLD_KEYBOARD_INT DD ? ;Location of old kbd interrupt
NEWPAD PROC NEAR ;The keyboard interrupt will now come here.
ASSUME CS:CODE_SEG
PUSH AX ;Save the used registers for good form
PUSH BX
PUSH CX
PUSH DX
PUSH DI
PUSH SI
PUSH DS
PUSH ES
PUSHF ;First, call old keyboard interrupt
CALL OLD_KEYBOARD_INT
ASSUME DS:ROM_BIOS_DATA ;Examine the char just put in
MOV BX,ROM_BIOS_DATA
MOV DS,BX
MOV BX,TAIL ;Point to current tail
CMP BX,HEAD ;If at head, kbd int has deleted char
JE IN ;So leave
SUB BX,2 ;Point to just read in character
CMP BX,OFFSET BUFFER ;Did we undershoot buffer?
JAE NO_WRAP ;Nope
MOV BX,OFFSET BUFFER_END ;Yes -- move to buffer top
SUB BX,2 ;Point to just read in characterqqq
NO_WRAP:MOV DX,[BX] ;Char in DX now
CMP DX,310EH ;Is the char a Cntrl-N?
JNE NOT_CNTRL_N ;No
MOV TAIL,BX ;Yes -- delete it from buffer
NOT CNTRL_N_FLAG ;Switch Modes
CMP CNTRL_N_FLAG,0 ;Cntrl-N off?
JNE CNTRL_N_ON ;No, only other choice is on
CNTRL_N_OFF:
LEA DX,PAD
MOV PAD_OFFSET,DX
ADD PAD_OFFSET,3000
LEA AX,PUT_CHAR ;Make IO call Put_Char as it scans
MOV IO_CHAR,AX ;over all locations in pad on screen
CALL IO ;Restore screen
IN: JMP OUT ;Done
CNTRL_N_ON:
LEA DX,PAD
MOV PAD_OFFSET,DX
ADD PAD_OFFSET,3000
LEA AX,GET_CHAR ;Make IO use Get_char so current screen
MOV IO_CHAR,AX ;is stored
CALL IO ;Store Screen
CALL DISPLAY ;And put up the pad
JMP OUT ;Done here.
NOT_CNTRL_N:
TEST CNTRL_N_FLAG,1 ;Is Cntrl-N on?
JZ IN ;No -- leave
MOV TAIL,BX ;Yes, delete this char from buffer
CMP DX,5300H ;Decide what to do -- is it a Delete?
JNE RUBOUT_TEST ;No -- try Rubout
PUSH DS
PUSH CS
POP DS
MOV BX,PAD_END
DEC BX
DEL_LOOP:
MOV BYTE PTR [BX],' ' ;Move space to current pad position
DEC BX ;and go back one
CMP BX,PAD_BEGIN
JNZ DEL_LOOP ;until done.
MOV BYTE PTR [BX],'_' ;Put the cursor at the beginning
MOV DX,PAD_BEGIN
MOV PAD_CURSOR,dx ;qq ;And start cursor over
POP DS
CALL DISPLAY ;Put up the new pad on screen
JMP OUT ;And take our leave
RUBOUT_TEST:
CMP DX,0E08H ;Is it a Rubout?
JNE CRLF_TEST ;No -- try carriage return-line feed
PUSH DS
PUSH CS
POP DS
MOV BX,PAD_CURSOR ;Yes -- get current pad location
CMP BX,PAD_BEGIN ;Are we at beginning?
JLE NEVER_MIND ;Yes -- can't rubout past beginning
MOV BYTE PTR [BX-1],'_' ;And move cursor back one
DEC PAD_CURSOR ;Set the pad location straight
CMP BX,PAD_END ;Save page number.
JE NEVER_MIND
MOV BYTE PTR [BX],' ' ;No -- move space to current position
NEVER_MIND:
POP DS
CALL DISPLAY ;And put the result on the screen
JMP OUT ;Done here.
CRLF_TEST:
CMP DX,1C0DH ;Is it a carriage return-line feed?
JNE PGUP_TEST ;No
PUSH DS
PUSH CS
POP DS
CALL CRLF ;Yes -- move to next line
POP DS
CALL DISPLAY ;And display result on screen
JMP OUT ;Done.
PGUP_TEST:
CMP DX,4900H
JNE PGDN_TEST
CMP PAGE_NUMBER,0
JNE DEC_PAGE
JMP OUT
DEC_PAGE:
MOV BX,PAGE_NUMBER ;STORE PAD CURSOR
ADD BX,BX
MOV CX,PAD_CURSOR
MOV CURSOR_STORAGE[BX],CX
DEC PAGE_NUMBER
SUB BX,2
MOV CX,CURSOR_STORAGE[BX]
MOV PAD_CURSOR,CX
MOV AX,PAGE_NUMBER
MOV BX,600
MUL BX
LEA DX,PAD
ADD AX,DX
MOV PAD_BEGIN,AX
ADD AX,599
MOV PAD_END,AX
CALL DISPLAY
JMP OUT
PGDN_TEST:
CMP DX,5100H
JNE F1_TEST
CMP PAGE_NUMBER,4
JNE INC_PAGE